package JDK8;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class StreamDemo01 {
    public static void main(String[] args) {
        List<Integer> list1 = Arrays.asList(10, 8, 3, 11, 15, 7, 9, 6);
        List<Integer> list2 = Arrays.asList(3, 8, 3, 11, 6, 20, 9, 6);

        Stream<Integer> stream = list1.stream();

        Stream<Integer> sorted = stream.sorted();

        sorted.forEach((n)-> System.out.println(n));
        System.out.println(list1);

        List<Integer> list3 =
                list2.stream()
                     .distinct()//去重
                     .map(e0->e0*2)//映射操作
                     .sorted((e1,e2)->e2-e1)//降序
                     .collect(Collectors.toList());// 将排序结果存储新的集合中
        System.out.println(list3);


//        list2.stream().sorted().forEach((n)-> System.out.println(n));


    }
}
